<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.6"/>
<title>uCXpresso.BLE: /peripheral/eeprom/src/main.cpp</title>
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../jquery.js"></script>
<script type="text/javascript" src="../../dynsections.js"></script>
<link href="../../navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../resize.js"></script>
<script type="text/javascript" src="../../navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="../../upnp.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">uCXpresso.BLE
   &#160;<span id="projectnumber">v1.0.4</span>
   </div>
   <div id="projectbrief">RTOS C++ Framework for Bluetooth Low Energy</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.6 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "../../search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="../../index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="../../modules.html"><span>Modules</span></a></li>
      <li><a href="../../annotated.html"><span>Classes</span></a></li>
      <li><a href="../../examples.html"><span>Examples</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="../../search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="../../search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('de/dd2/_2peripheral_2eeprom_2src_2main_8cpp-example.html','../../');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Groups</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">/peripheral/eeprom/src/main.cpp</div>  </div>
</div><!--header-->
<div class="contents">
<p>This is an example of how to use the <a class="el" href="../../d0/d7a/class_e_e_p_r_o_m.html">EEPROM</a> class. More details about this example.</p>
<div class="fragment"><div class="line"><span class="comment">/*</span></div>
<div class="line"><span class="comment"> ===============================================================================</span></div>
<div class="line"><span class="comment"> Name        :</span></div>
<div class="line"><span class="comment"> Author      :</span></div>
<div class="line"><span class="comment"> Version     : v1.0.0</span></div>
<div class="line"><span class="comment"> Date        :</span></div>
<div class="line"><span class="comment"> Copyright   :</span></div>
<div class="line"><span class="comment"> Description :</span></div>
<div class="line"><span class="comment"> ===============================================================================</span></div>
<div class="line"><span class="comment">                                 History</span></div>
<div class="line"><span class="comment"> ---------+---------+--------------------------------------------+-------------</span></div>
<div class="line"><span class="comment"> DATE     | VERSION |   DESCRIPTIONS                             |  By</span></div>
<div class="line"><span class="comment"> ---------+---------+--------------------------------------------+-------------</span></div>
<div class="line"><span class="comment"></span></div>
<div class="line"><span class="comment"> ===============================================================================</span></div>
<div class="line"><span class="comment"> */</span></div>
<div class="line"></div>
<div class="line"><span class="preprocessor">#include &quot;uCXpresso.h&quot;</span></div>
<div class="line"><span class="preprocessor">#include &quot;class/serial.h&quot;</span></div>
<div class="line"><span class="preprocessor">#include &quot;class/usb_cdc.h&quot;</span></div>
<div class="line"></div>
<div class="line"><span class="preprocessor">#ifdef DEBUG</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#include &quot;debug.h&quot;</span></div>
<div class="line"><span class="preprocessor">#define DBG     dbg_printf</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#else</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#define DBG(...)</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#endif</span></div>
<div class="line"><span class="preprocessor"></span></div>
<div class="line"><span class="comment">//</span></div>
<div class="line"><span class="comment">// TODO: insert other include files here</span></div>
<div class="line"><span class="comment">//</span></div>
<div class="line"><span class="preprocessor">#include &quot;class/eeprom.h&quot;</span></div>
<div class="line"></div>
<div class="line"><span class="comment">//</span></div>
<div class="line"><span class="comment">// TODO: insert other definitions and declarations here</span></div>
<div class="line"><span class="comment">//</span></div>
<div class="line"></div>
<div class="line"><span class="comment">//</span></div>
<div class="line"><span class="comment">// LED Demo (can be removed)</span></div>
<div class="line"><span class="comment">//</span></div>
<div class="line"><span class="preprocessor">#include &quot;class/bus.h&quot;</span></div>
<div class="line"><span class="keyword">static</span> <span class="keyword">const</span> uint8_t led_scripts[] = { <span class="comment">// bit0=LED1, bit1=LED2, bit2=LED3, bit4=LED4</span></div>
<div class="line">    1, 2, 4, 8, 4, 2</div>
<div class="line">};</div>
<div class="line"></div>
<div class="line"><span class="comment">//</span></div>
<div class="line"><span class="comment">// main task</span></div>
<div class="line"><span class="comment">//</span></div>
<div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">void</span>) {</div>
<div class="line"></div>
<div class="line"><span class="preprocessor">#ifdef DEBUG</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">    #if __USE_USB</span></div>
<div class="line"><span class="preprocessor"></span>        <a name="_a0"></a><a class="code" href="../../d6/dc5/classusb_c_d_c.html">usbCDC</a> ser;</div>
<div class="line">        ser.<a name="a1"></a><a class="code" href="../../d6/dc5/classusb_c_d_c.html#a49d431de50da7ccacf91ef33b04e99d2">connect</a>();</div>
<div class="line"><span class="preprocessor">    #else</span></div>
<div class="line"><span class="preprocessor"></span>        <a name="_a2"></a><a class="code" href="../../d8/d1d/class_c_serial.html">CSerial</a> ser;</div>
<div class="line">        ser.<a name="a3"></a><a class="code" href="../../d8/d1d/class_c_serial.html#a0c80ea521e310305579e787f21a55233">settings</a>(115200);</div>
<div class="line"><span class="preprocessor">    #endif</span></div>
<div class="line"><span class="preprocessor"></span>    <a name="_a4"></a><a class="code" href="../../d4/d37/class_c_debug.html">CDebug</a> dbg(ser);</div>
<div class="line">    dbg.start();</div>
<div class="line"><span class="preprocessor">#endif</span></div>
<div class="line"><span class="preprocessor"></span></div>
<div class="line">    <span class="comment">//</span></div>
<div class="line">    <span class="comment">// LED Demo (can be removed)</span></div>
<div class="line">    <span class="comment">//</span></div>
<div class="line">    DBG(<span class="stringliteral">&quot;Hello I&#39;m in debug mode\n&quot;</span>);</div>
<div class="line">    uint8_t i = 0;</div>
<div class="line">    <a name="_a5"></a><a class="code" href="../../de/d89/class_c_bus.html">CBus</a> port(<a name="a6"></a><a class="code" href="../../db/dff/group___enumerations.html#gga65a2241721e4acb573e0c3fe29ac432fadac6477842247cab1a8c02c65f431b44">LED1</a>, <a name="a7"></a><a class="code" href="../../db/dff/group___enumerations.html#gga65a2241721e4acb573e0c3fe29ac432fa8379bbaa96d151e6adac488b2a147b7a">LED2</a>, <a name="a8"></a><a class="code" href="../../db/dff/group___enumerations.html#gga65a2241721e4acb573e0c3fe29ac432fa5dec293e081e0fc78369c842fab8452b">LED3</a>, <a name="a9"></a><a class="code" href="../../db/dff/group___enumerations.html#gga65a2241721e4acb573e0c3fe29ac432fad60e39b8d1701d30aa64f80343217342">LED4</a>, <a name="a10"></a><a class="code" href="../../db/dff/group___enumerations.html#gga65a2241721e4acb573e0c3fe29ac432fadc6f24fd6915a3f2786a1b7045406924">END</a>);</div>
<div class="line">    port.output();  <span class="comment">// set all pins as output</span></div>
<div class="line"></div>
<div class="line">    <span class="comment">//</span></div>
<div class="line">    <span class="comment">// your setup code here</span></div>
<div class="line">    <span class="comment">//</span></div>
<div class="line">dbg.waitToDebugMode();  <span class="comment">// &lt;-- please enter to debug mode</span></div>
<div class="line">    uint8_t buf[4];</div>
<div class="line"></div>
<div class="line">    <span class="comment">// read from EEPROM and check it when power on</span></div>
<div class="line">    <a name="a11"></a><a class="code" href="../../d0/d7a/class_e_e_p_r_o_m.html#a47f3f52eed97b6e43b830ce4a1dc495e">EEPROM::read</a>(0, buf, <span class="keyword">sizeof</span>(buf));</div>
<div class="line">    DBG(<span class="stringliteral">&quot;%02X %02X %02X %02X\n&quot;</span>, buf[0], buf[1], buf[2], buf[3]);</div>
<div class="line"></div>
<div class="line">    <span class="comment">// write back to EEPROM</span></div>
<div class="line">    buf[0] = 0xAA;</div>
<div class="line">    buf[1] = 0xAA;</div>
<div class="line">    buf[2] = 0x55;</div>
<div class="line">    buf[3] = 0x55;</div>
<div class="line">    <a name="a12"></a><a class="code" href="../../d0/d7a/class_e_e_p_r_o_m.html#a8c397be98d4762869715a2a07866af6b">EEPROM::write</a>(0, buf, <span class="keyword">sizeof</span>(buf));   <span class="comment">// &lt;-- please power off and on (reset) again to check EEPROM contents</span></div>
<div class="line"></div>
<div class="line">    <span class="keywordflow">while</span>(1) {</div>
<div class="line">        <span class="comment">//</span></div>
<div class="line">        <span class="comment">// LED Demo (can be removed)</span></div>
<div class="line">        <span class="comment">//</span></div>
<div class="line">        port = led_scripts[i];</div>
<div class="line">        i = (i+1) &lt; <span class="keyword">sizeof</span>(led_scripts) ? i+1 : 0;</div>
<div class="line">        sleep(100);</div>
<div class="line"></div>
<div class="line">        <span class="comment">//</span></div>
<div class="line">        <span class="comment">// your loop code here</span></div>
<div class="line">        <span class="comment">//</span></div>
<div class="line"></div>
<div class="line">    }</div>
<div class="line">    <span class="keywordflow">return</span> 0 ;</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line"><span class="comment">//</span></div>
<div class="line"><span class="comment">// default memory pool</span></div>
<div class="line"><span class="comment">//</span></div>
<div class="line"><span class="keyword">static</span> uint8_t mem_pool[DEFAULT_POOL_SIZE];</div>
<div class="line"></div>
<div class="line"><span class="comment">//</span></div>
<div class="line"><span class="comment">// setup before the system startup</span></div>
<div class="line"><span class="comment">//</span></div>
<div class="line"><span class="keyword">extern</span> <span class="stringliteral">&quot;C&quot;</span> <span class="keywordtype">void</span> sys_setup(<span class="keywordtype">void</span>) {</div>
<div class="line">    pool_memadd((uint32_t)mem_pool, <span class="keyword">sizeof</span>(mem_pool));</div>
<div class="line"><span class="preprocessor">#if __USE_USB==0</span></div>
<div class="line"><span class="preprocessor"></span>    pool_memadd(USB_MEM_BASE, USB_MEM_SIZE);</div>
<div class="line"><span class="preprocessor">#endif</span></div>
<div class="line"><span class="preprocessor"></span>}</div>
<div class="line"></div>
</div><!-- fragment --> </div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated on Fri Apr 11 2014 23:43:26 for uCXpresso.BLE by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="../../doxygen.png" alt="doxygen"/></a> 1.8.6 </li>
  </ul>
</div>
</body>
</html>
